TQ3ObjectReadDataMethod
You can define a method to read an object of your custom type and any attached subobjects from a file object.
typedef TQ3Status (*TQ3ObjectReadDataMethod) ( TQ3Object parentObject, TQ3FileObject file);
parentObject
- An object to attach your custom data to.
file
- A file object.
DESCRIPTION
YourTQ3ObjectReadDataMethod
function should read an object and any attached subobjects from the current location in the file object specified by thefile
parameter and attach that object to the object specified by theparentObject
parameter. If the object read is a custom element (or a custom attribute), you should allocate space on the stack and callQ3Set_Add
(orQ3AttributeSet_Add
) on the object specified by theparentObject
parameter, which is a set (or an attribute set). If the object read is not an element, you should attach your custom data to the object specified by theparentObject
parameter.On entrance to your custom read method, you should read the custom object data using the primitive data type
_Read
functions described in "Reading and Writing File Data," beginning on page 17-27 (for example,Q3Uns64_Read
andQ3Point3D_Read
). In general, you know the structure of the custom object data, so you can stop reading when you've read an entire object. Alternatively, you can read data until the functionQ3File_IsEndOfData
returnskQ3True
.Once you've read the custom object data, you should read any subobjects attached to the object. Because a metafile object has subobjects only if it is in a container, you can use the
Q3File_IsEndOfContainer
function to determine whether there are any subobjects (ifQ3File_IsEndOfContainer
returnskQ3False
, there are subobjects to read). If you have created an object, pass it toQ3File_IsEndOfContainer
so that the subobjects with automatic attachment methods can be attached to your object. Otherwise, pass the valueNULL
toQ3File_IsEndOfContainer
to have all subobjects returned to you. Note that when you callQ3File_IsEndOfContainer
, all unread parent object data is skipped and a warning is issued.At this point, you can use the functions that retrieve subobjects (for example,
Q3File_GetNextObjectType
and Q3File_ReadObject) to iterate through the subobjects untilQ3File_IsEndOfContainer
returnskQ3True
.RESULT CODES
YourTQ3ObjectReadDataMethod
function should returnkQ3Success
if it is successful andkQ3Failure
otherwise.